package ClientDB;

import java.util.ArrayList;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import DataConnectionInterface.*;

public class CardDeck {
    final private int deckSize; /*you can change this as u see fit*/
    private ArrayList<ICard> cards;
    private int cardsHanded;
    private ICard emptyCard;
    private ICard rivalCard;
    
    public CardDeck(Display display, ArrayList<Card> cardsList) {
    	this.deckSize = cardsList.size();
        this.cardsHanded = 0;
        
        //this.emptyCard = new ICard(new Image(display, "default.png"), 0, 0, "");
        this.emptyCard = new ICard(new Image(display, "card-def2.jpg"), 0, 0, "");
        
        //this.rivalCard = new ICard(new Image(display, "02b32bh.jpeg"), 0 ,0, "");
        this.rivalCard = new ICard(new Image(display, "card-play.jpg"), 0 ,0, "");
        
        cards = new ArrayList<ICard>(); 
        initDeck(display, cardsList);
    }

    /*TODO!!! this you need to implement*/
    private void initDeck(Display display, ArrayList<Card> cardsList) {
        //Image p1 = new Image(display, "029xczn.png");
    	Image p1 = new Image(display, "card-play.jpg");
    	
        for(Card card: cardsList) {
        	cards.add(new ICard(p1, card.getAttack(), card.getDefense(), card.getName()));
        }
    }

    public ICard getNextCard() {
        if(cardsHanded >= deckSize) return emptyCard;
        ICard result = cards.get(cardsHanded);
        this.cardsHanded++;
        return result;
    }

    public ICard getEmptyCard() {
        return emptyCard;
    }
    
    public ICard getRivalCard(){
    	return rivalCard;
    }

    public int getCardsLeft() {
        return deckSize-cardsHanded;
    }

    public int getCardsHanded() {
        return cardsHanded;
    }
}
 